import { defineStore } from "pinia";

export const useSchoolStore = defineStore("school", {
  state() {
    return {
      area: "area",
      areaNo: 1,
    };
  },
  // 开启数据缓存
  persist: {
    enabled: true,
    strategies: [
      {
        key: "my_school", // 自定义存储的值的key，默认使用store的id作为key，默认值:school
        storage: localStorage, // 持久化存储位置，默认使用sessionStorage
        paths: ["area"], // 部分持久化，默认全部持久化
      },
    ],
  },
  getters: {
    getFullInfo(state) {
      return { area: state.area, areaNo: state.areaNo };
    },
  },
  actions: {
    setAn0therSchool(area: string, no: number) {
      this.area = area;
      this.areaNo = no;
    },
  },
});
